<template>
  <div>
    xiugai
    <h1>{{ title }}</h1>
  </div>
</template>

<script>
export default {
  name: 'SaveOrUpdate',
  data() {
    return {
      title:' '
    }
  },
  created(){
    console.log("@",this.$route.params.id)
    // 取不到值为false，取到值为true
    if(this.$route.params.id){
      this.title = "修改"
      console.log("执行了")
    }else{
      this.title = "新增"
    }
  },
  watch:{
    $route(from,to){
      console.log(from)
      console.log(to)
      console.log(this.$route.params.id)
      if(this.$route.params.id){
        this.title = "新增"
      }else{
        this.title = "修改"
      }
    }
  },
  methods: {

  }
}
</script>
<style scoped>
</style>
